﻿using Glue;
using Glue.Converters;
using Xunit;

namespace GlueTests.BaseConverterTests
{
    public class When_an_exception_is_thrown_in_inheritor
    {
        [Fact]
        public void Should_throw_GlueException_on_OverflowException_in_childObject()
        {
            var biggerThanByte = "33333333333";
            var converter = new ByteStringConverter();
            Assert.Throws<GlueException>(() =>
                converter.MapTowardsLeft(biggerThanByte)
             );
        }

        [Fact]
        public void Should_throw_GlueException_on_FormatException_in_childObject()
        {
            var biggerThanByte = "abc";
            var converter = new ByteStringConverter();
            Assert.Throws<GlueException>(() =>
                converter.MapTowardsLeft(biggerThanByte)
             );
        }

        [Fact]
        public void Should_throw_GlueException_in_class_directly_inherited_from_BaseConverter()
        {
            var biggerThanInt = "12345678912345";
            IConverter converter = new TestConverterBetweenStringAndInt();
            Assert.Throws<GlueException>(() =>
                converter.Map(biggerThanInt, 0));
        }
    }
}
